package com.glsc.ngateway.common.base.converter.platform;

import com.alibaba.excel.util.CollectionUtils;
import com.glsc.ngateway.common.api.flowable.dto.FlowFormNewDevicePartStandardDetailDto;
import com.glsc.ngateway.common.base.domain.mysql.gateway.platform.flow.cmdb.FlowFormNewDevicePartStandardDetail;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * @author xuchang
 */
public class FlowFormNewDevicePartStandardDetailConverter {

    public static FlowFormNewDevicePartStandardDetailDto do2Dto(FlowFormNewDevicePartStandardDetail domain) {
        if (Objects.isNull(domain)) {
            return null;
        }
        return FlowFormNewDevicePartStandardDetailMapper.INSTANCE.do2Dto(domain);
    }

    public static List<FlowFormNewDevicePartStandardDetailDto> do2Dto(List<FlowFormNewDevicePartStandardDetail> domainList) {
        return CollectionUtils.isEmpty(domainList) ? java.util.Collections.emptyList() : domainList.stream().map(FlowFormNewDevicePartStandardDetailConverter::do2Dto).collect(Collectors.toList());
    }

    public static FlowFormNewDevicePartStandardDetail dto2Do(FlowFormNewDevicePartStandardDetailDto dto) {
        if (Objects.isNull(dto)) {
            return null;
        }
        return FlowFormNewDevicePartStandardDetailMapper.INSTANCE.dto2Do(dto);
    }

    public static List<FlowFormNewDevicePartStandardDetail> dto2Do(List<FlowFormNewDevicePartStandardDetailDto> dtoList) {
        return CollectionUtils.isEmpty(dtoList) ? java.util.Collections.emptyList() : dtoList.stream().map(FlowFormNewDevicePartStandardDetailConverter::dto2Do).collect(Collectors.toList());
    }

    @Mapper(componentModel = "spring")
    public interface FlowFormNewDevicePartStandardDetailMapper {

        FlowFormNewDevicePartStandardDetailMapper INSTANCE = Mappers.getMapper(FlowFormNewDevicePartStandardDetailMapper.class);

        FlowFormNewDevicePartStandardDetailDto do2Dto(FlowFormNewDevicePartStandardDetail domain);

        List<FlowFormNewDevicePartStandardDetailDto> do2Dto(List<FlowFormNewDevicePartStandardDetail> domain);

        FlowFormNewDevicePartStandardDetail dto2Do(FlowFormNewDevicePartStandardDetailDto dto);

        List<FlowFormNewDevicePartStandardDetail> dto2Do(List<FlowFormNewDevicePartStandardDetailDto> dto);
    }
}
